package com.orangecy.loglevel;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author : orangeCy.奕
 * @Time : 2021/9/29
 * @desc : 猎豹养成产品源码
 */
@Data
public class LogData {

    /**
     * 日志入参 支持多个入参
     */
    private List<Object> params;

    /**
     * 日志结果
     */
    private Object result;

    /**
     * 日志的描述信息，便于关键字搜索
     */
    private String desc;


    @Override
    public String toString() {
        return new StringBuilder().append("[ desc: | ").append(desc).append(" | ")
                .append("param:").append(JSON.toJSONString(params)).append(" | ")
                .append("result:").append(JSON.toJSONString(result)).append(" ]").toString();
    }

    public LogData param(Object... param){
        if(params == null) {
            params = new ArrayList<>();
            this.params.add(param);
        }else{
            this.params.add(param);
        }
        return this;
    }

    public LogData result(Object result) {
        this.result = result;
        return this;
    }

    public LogData desc(String desc) {
        this.desc = desc;
        return this;
    }

    static LogData builder() {
        return new LogData();
    }

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        int i = 0;
        while (true) {
            list.add(String.valueOf(++i).intern());
        }
    }
}
